package com.example.demo.business.controller;

import java.util.List;

import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.example.demo.business.feign.MemberFeign;
import com.example.demo.business.feign.TradeFeign;
import com.example.demo.business.model.Dog;

import jakarta.annotation.Resource;

@RequestMapping("/business")
@RestController
public class BusinessController {

    @Resource
    private MemberFeign memberFeign;
    @Resource
    private TradeFeign  tradeFeign;

    @RequestMapping("/member/test")
    public String memberTest(Integer id) {
        String result = memberFeign.test();
        return "business member test: " + result;
    }

    @RequestMapping("/get")
    public String test(String type, Integer id) {
        List<Dog> list = memberFeign.list(type, id);
        return list.toString();
    }

    @RequestMapping("/getById")
    public String getById(Integer id) {
        String s = memberFeign.getById(id);
        return s;
    }

    @PostMapping("/save")
    public void save(@RequestBody Dog dog) {
        memberFeign.save(dog);
    }

    @PostMapping("/saveBatch")
    public void saveBatch(@RequestBody List<Dog> list) {
        memberFeign.saveBatch(list);
    }

    @RequestMapping("/test")
    public String test() {
        String list = tradeFeign.list();
        return list;
    }

}
